﻿@using System.Net.Http.Formatting
@model DBTramite.BussinesEntities.T_Documento

@{
    ViewBag.Title = "Create";item
}

<h2 class="tabla-bordes-2" style="background: lightskyblue">Registro de Nuevo Expediente</h2>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)


    <div class="panel panel-primary">
        <div class="panel-heading">
            Registrar Documento
        </div>
        <div class="panel-body">
            <table>
                    <tr>
                        <td><b style="color: #000" />Destino</td>
                <td>
                    @(Html.Kendo().AutoComplete()
                        .Name("destino")
                        .DataTextField("nombre")
                        .Placeholder("Seleccionar un Destino...")
                        .MinLength(1)
                        .Filter("startswith") //aca nomas se pone starWish 
                        .HtmlAttributes(new { style = "width:auto" })
                        .DataSource(source =>  {
                            source.Read(read => { read.Action("Listar", "Documento"); });
                        })
                    )
            
                    </td>
            </tr>
            </table>
            <div class="form-horizontal">
               
                    
                    <table>
                        <tr>
                            <td>
                                <div class="form-group">
                                    @Html.LabelFor(model => model.nroexpediente,new{@class="col-sm-2 control-label"})
                                </div>
                            </td> 
                            <td>
                                <div class="col-sm-10">
                                    @Html.EditorFor(model => model.nroexpediente,null,new{@class="form-control"})
                                    @Html.ValidationMessageFor(model => model.nroexpediente)
                                </div>
                            </td>
                            
                            <td>
                                <div class="form-group">
                                @Html.LabelFor(model => model.fechaingreso,new{@class="col-sm-2 control-label"})
                   
                                </div>
                            </td>
                            <td>
                                <div class="col-sm-10">
                                    @Html.EditorFor(model => model.fechaingreso)
                                    @Html.ValidationMessageFor(model => model.fechaingreso)
                                </div>
                            </td>
                            
                        <tr>
                            <td>
                                <div class="form-group">Tipo Documento
                                    @* @Html.LabelFor(model => model.codtipodocumento,new{@class="col-sm-2 control-label"})*@
                    
                                </div>
                            </td>
                            <td>
                                <div class="col-sm-10">
                                      @Html.DropDownList("Expediente", new MultiSelectList(new[] { " ","OFICIO", "OFICIO MULTIPLE"
                                      , "SOLICITUD", "RESOLUCION DIRECTORAL", "RESOLUCION RECTORAL"
                                      , "RESOL. RECT. DE CONSEJO UNIV.", "INFORME", "MEMORANDUM"
                                      , "MEMORANDUM MULTIPLE", "CITACION", "ELEVACION","CARTA"}))
                                      @Html.ValidationMessageFor(model => model.T_Tipodocumento)

                                    @* @Html.EditorFor(model => model.codtipodocumento)
                                    @Html.ValidationMessageFor(model => model.codtipodocumento)*@
                                </div>
                            </td>
                            
                            <td>
                                <div class="form-group">
                                  @Html.LabelFor(model => model.nrodocumento,new{@class="col-sm-2 control-label"})
                    
                                </div>
                            </td>
                            
                            <td>
                                <div class="col-sm-10">
                                    @Html.EditorFor(model => model.nrodocumento)
                                    @Html.ValidationMessageFor(model => model.nrodocumento)
                                </div>
                            </td>
                        
                            <tr>
                                <td><b style="color: #000" />Procedencia</td>
                                <td>
                                    @(Html.Kendo().AutoComplete()
                                          .Name("codemisor")
                                          .DataTextField("nombres")
                                          .Placeholder("Seleccionar un Procedencia...")
                                          .MinLength(1)
                                          .Filter("startswith") //aca nomas se pone starWish 
                                          .HtmlAttributes(new { style = "width:auto" })
                                          .DataSource(source =>  {
                                                                     source.Read(read => { read.Action("Procedencia", "Documento"); });
                                          })
                                          )
                                </td>
                            </tr>
                        <tr>
                            <td>
                                <div class="form-group">
                                    @Html.LabelFor(model => model.asunto,new{@class="col-sm-2 control-label"})
                   
                                </div>
                            </td>
                            <td>
                                <div class="col-sm-10">
                                    @Html.EditorFor(model => model.asunto)
                                    @Html.ValidationMessageFor(model => model.asunto)
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="form-group">
                                    @Html.LabelFor(model => model.folios,new{@class="col-sm-2 control-label"})
                                   
                                </div> 
                            </td>
                            <td>
                                 <div class="col-sm-10">
                                        @Html.EditorFor(model => model.folios)
                                        @Html.ValidationMessageFor(model => model.folios)
                                    </div>
                            </td>
                        </tr>
                        
                        <tr>
                            <td>
                            <div class="form-group">
                                @Html.LabelFor(model => model.telefono,new{@class="col-sm-2 control-label"})
                                    
                            </div>
                            <td>
                                <div class="col-sm-10">
                                    @Html.EditorFor(model => model.telefono)
                                    @Html.ValidationMessageFor(model => model.telefono)
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="form-group">
                                    @Html.LabelFor(model => model.observacion,new{@class="col-sm-2 control-label"})
                                   
                                </div>
                            </td>
                            <td>
                                <div class="col-sm-10">
                                    @Html.EditorFor(model => model.observacion)
                                    @Html.ValidationMessageFor(model => model.observacion)
                                </div>
                            </td>
                        <tr>
                            <td>
                                <div>
                                    @Html.ActionLink("Documento Registrados", "Index")
                                </div> 
                                              
                            </td> 

                        </tr>

                    </table>
                   
                @*<div class="form-group">
                    @Html.LabelFor(model => model.expgenerador,new{@class="col-sm-2 control-label"})
                    <div class="col-sm-10">
                        @Html.EditorFor(model => model.expgenerador)
                        @Html.ValidationMessageFor(model => model.expgenerador)
                    </div>
                </div>
                
                <div class="form-group">
                    @Html.LabelFor(model => model.codemisor,new{@class="col-sm-2 control-label"})
                    <div class="col-sm-10">
                        @Html.EditorFor(model => model.codemisor)
                        @Html.ValidationMessageFor(model => model.codemisor)
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(model => model.id_dep,new{@class="col-sm-2 control-label"})
                    <div class="col-sm-10">
                        @Html.EditorFor(model => model.id_dep)
                        @Html.ValidationMessageFor(model => model.id_dep)
                    </div>
                </div>
                
                <div class="form-group">
                    @Html.LabelFor(model => model.rut,new{@class="col-sm-2 control-label"})
                    <div class="col-sm-10">
                        @Html.EditorFor(model => model.rut)
                        @Html.ValidationMessageFor(model => model.rut)
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(model => model.id_old,new{@class="col-sm-2 control-label"})
                    <div class="col-sm-10">
                        @Html.EditorFor(model => model.id_old)
                        @Html.ValidationMessageFor(model => model.id_old)
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(model => model.nrodocumento,new{@class="col-sm-2 control-label"})
                    <div class="col-sm-10">
                        @Html.EditorFor(model => model.nroexpinterno)
                        @Html.ValidationMessageFor(model => model.nroexpinterno)
                    </div>
                </div>
              
                <div class="form-group">
                    @Html.LabelFor(model => model.fechasalida,new{@class="col-sm-2 control-label"})
                    <div class="col-sm-10">
                        @Html.EditorFor(model => model.fechasalida)
                        @Html.ValidationMessageFor(model => model.fechasalida)
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(model => model.permanenciamax,new{@class="col-sm-2 control-label"})
                    <div class="col-sm-10">
                        @Html.EditorFor(model => model.permanenciamax)
                        @Html.ValidationMessageFor(model => model.permanenciamax)
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(model => model.prioridad,new{@class="col-sm-2 control-label"})
                    <div class="col-sm-10">
                        @Html.EditorFor(model => model.prioridad)
                        @Html.ValidationMessageFor(model => model.prioridad)
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(model => model.recepcion,new{@class="col-sm-2 control-label"})
                    <div class="col-sm-10">
                        @Html.EditorFor(model => model.recepcion)
                        @Html.ValidationMessageFor(model => model.recepcion)
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(model => model.recepcion_old,new{@class="col-sm-2 control-label"})
                    <div class="col-sm-10">
                        @Html.EditorFor(model => model.recepcion_old)
                        @Html.ValidationMessageFor(model => model.recepcion_old)
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(model => model.codtipotramite,new{@class="col-sm-2 control-label"})
                    <div class="col-sm-10">
                        @Html.EditorFor(model => model.codtipotramite)
                        @Html.ValidationMessageFor(model => model.codtipotramite)
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(model => model.codestado,new{@class="col-sm-2 control-label"})
                    <div class="col-sm-10">
                        @Html.EditorFor(model => model.codestado)
                        @Html.ValidationMessageFor(model => model.codestado)
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(model => model.codexpinicial,new{@class="col-sm-2 control-label"})
                    <div class="col-sm-10">
                        @Html.EditorFor(model => model.codexpinicial)
                        @Html.ValidationMessageFor(model => model.codexpinicial)
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(model => model.interno,new{@class="col-sm-2 control-label"})
                    <div class="col-sm-10">
                        @Html.EditorFor(model => model.interno)
                        @Html.ValidationMessageFor(model => model.interno)
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(model => model.fecha_audit,new{@class="col-sm-2 control-label"})
                    <div class="col-sm-10">
                        @Html.EditorFor(model => model.fecha_audit)
                        @Html.ValidationMessageFor(model => model.fecha_audit)
                    </div>
                </div>*@
                
                <button id="btnAgregarUnidad" type="button" class="btn btn-warning">Agregar Adjunto</button>
                <table id="tbAdjunto" class="table table-hover">
                    <thead>
                        <tr>
                            <th>Cantidad</th>
                            <th>Unidad</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><input type="text"  name="T_Unidadenvio[0].cantidad" class="form-control" ></td>
                            <td>
                                @Html.DropDownList("T_Unidadenvio[0].codunidad",null,new{@class="form-control"})
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="panel-footer">
             <input type="submit" value="Create" class="btn btn-success" />
        </div>
    </div>


    
    
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    <script type="text/javascript">
        $(function () {
             
            $("#btnAgregarUnidad").click(function (e) {
                e.preventDefault();
                 
                var table = $('#tbAdjunto > tbody');
                var rows = $('#tbAdjunto > tbody > tr').length;

                var row = table.find('tr').last();
                 
                row.find('td :eq(1)').find('select').addClass("form-control");
                 
                var newrow = row.clone();

                newrow.find('td :eq(0)').find('input').attr("name", "T_Unidadenvio[" + rows + "].cantidad");
                newrow.find('td :eq(1)').find('select').attr("name", "T_Unidadenvio[" + rows + "].codunidad");

                row.after(newrow);

            });
        });
         
    </script>

}
